package JavaBase;
/*
以(OO)面向对象的思想，编写自定义类描述IT从业者。
属性：姓名(name)、年龄(age)、技术方向(skillDir)、工作年限(jobOfYears)；
方法：工作(working)
要求：(1)、限定IT从业人员必须年满18岁，无效信息需提示，并且设置默认年龄为18岁。
      (2)、工作方法通过输入参数，接收工作单位和职务，输出个人工作信息。
      (3)、编写测试类，测试IT从业者类的对象及相关方法。(测试数据信息自定)。
 */
public class ITPerson {
    private String name;
    private int age;
    private String skillDir;
    private int jobOfYears;
    private String workUnit;
    private String post;
    public ITPerson()
    {
        this.name="无名";
        this.age=18;
        this.skillDir="未知";
        this.jobOfYears=5;
        this.workUnit="未知";
        this.post="未知";
    }
    public ITPerson(String name,int age,String skillDir,int jobOfYears,String workUnit,String post)
    {
        this.age=age;
        this.name=name;
        this.jobOfYears=jobOfYears;
        this.skillDir=skillDir;
        this.workUnit=workUnit;
        this.post=post;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public String getWorkUnit() {
        return workUnit;
    }

    public void setWorkUnit(String workUnit) {
        this.workUnit = workUnit;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age>150||age<18)
        {
            System.out.println("年龄无效！重置为18岁");
        }
        else
        {
            this.age = age;
        }
    }

    public int getJobOfYears() {
        return jobOfYears;
    }

    public void setJobOfYears(int jobOfYears) {
        this.jobOfYears = jobOfYears;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSkillDir() {
        return skillDir;
    }

    public void setSkillDir(String skillDir) {
        this.skillDir = skillDir;
    }

    public void working(String workUnit,String post)
    {
        this.workUnit=workUnit;
        this.post=post;
        System.out.println("IT程序员的姓名："+this.name);
        System.out.println("年龄："+this.age);
        System.out.println("技术方向："+this.skillDir);
        System.out.println("工作年限："+this.jobOfYears);
        System.out.println("工作单位："+this.workUnit);
        System.out.println("职位："+this.post);
    }
}
